package com.victor.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.victor.entity.txt.BgIntroduction;
import com.victor.entity.txt.PrizesSetList;
import com.victor.entity.txt.PrizesSetMsg;
import com.victor.entity.txt.Selection;
import com.victor.service.TxtService;
import com.victor.utils.Msg;

/**
 * 文字相关Controller
 * 
 * @author Mr.Zhang
 *
 */
@RestController
@RequestMapping("/txt")
public class TxtController {

	@Autowired
	private TxtService txtService;

	/**
	 * 背景介绍和远景展望
	 */
	// 获取 背景介绍和远景展望
	@RequestMapping("/getBgIntroduction")
	public Msg getBgIntroduction() {
		BgIntroduction bgIntroduction = txtService.getBgIntroduction();
		return Msg.success().add("bgIntroduction", bgIntroduction);
	}

	// 修改 背景介绍和远景展望
	@RequestMapping("/updBgIntroduction")
	public Msg updBgIntroduction(BgIntroduction bgIntroduction) {
		boolean updResult = txtService.updBgIntroduction(bgIntroduction);
		return Msg.judge(updResult);
	}

	/**
	 * 奖项设置
	 */
	// 获取 奖项设置 页所有信息
	@RequestMapping("/getPrizesSet")
	public Msg getPrizesSet() {
		// 获取奖项设置页面信息
		PrizesSetMsg prizesSetMsg = txtService.getPrizesSetMsg();
		// 获取奖项设置列表
		List<PrizesSetList> prizesSetLists = txtService.getPrizesSetList();
		if (prizesSetLists != null && prizesSetLists.size() > 0) {
			prizesSetMsg.setPrizesSetLists(prizesSetLists);
		}
		return Msg.success().add("prizesSet", prizesSetMsg);
	}

	// 修改 奖项设置 页信息
	@RequestMapping("/updPrizesSetMsg")
	public Msg updPrizesSetMsg(PrizesSetMsg prizesSetMsg) {
		// 修改奖项设置信息
		boolean updResult = txtService.updPrizesSetMsg(prizesSetMsg);
		if (updResult) {
			return Msg.success();
		}
		return Msg.fail();
	}

	// 修改奖项设置
	@RequestMapping("/updPrizesSetList")
	public Msg updPrizesSetList(PrizesSetList prizesSetList) {
		boolean updResult=  txtService.updPrizesSetList(prizesSetList);
		return Msg.judge(updResult);
	}
	
	// 添加奖项设置
	@RequestMapping("/addPrizesSet")
	public Msg addPrizesSet(PrizesSetList prizesSet) {
		boolean addResult = txtService.addPrizesSet(prizesSet);
		if (addResult) {
			return Msg.success();
		}
		return Msg.fail();
	}

	// 批删奖项设置
	@RequestMapping("/batchDelPrizesSet")
	public Msg batchDelPrizesSet(int[] ids) {
		boolean delResult = txtService.batchDelPrizesSet(ids);
		return Msg.judge(delResult);
	}

	/**
	 * 评选方法及步骤
	 */
	// 获取评选方法及步骤
	@RequestMapping("/getSelectionList")
	public Msg getSelectionList() {
		List<Selection> selections = txtService.getSelectionList();
		return Msg.success().add("selections", selections);
	}

	// 修改评选方法或步骤
	@RequestMapping("/updSelection")
	public Msg updSelection(Selection selection) {
		boolean updResult = txtService.updSelection(selection);
		return Msg.judge(updResult);
	}
}
